package concurrency.chapter6;

public class ThreadInterrupt2 {

    public static void main(String[] args) throws InterruptedException {

        //final修饰的Thread，java8之后的语法糖
        Thread t3 = new Thread() {
            @Override
            public void run() {
                while (true) {

                }
            }
        };
        t3.start();
        Thread main = Thread.currentThread();
        Thread t4 = new Thread() {
            @Override
            public void run() {
                try {
                    Thread.sleep(4000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                //t3.interrupt();
                main.interrupt();//join的不是t3，而是main线程？？？对这句话的理解？？？不懂
                System.out.println("interrupt");
            }
        };
        t4.start();

        t3.join();
    }
}
